home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWPart / Sources / FWPresen.cpp < prev    next >
Encoding:
Text File  |  1996-04-25  |  22.4 KB  |  716 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWPresen.cpp
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFrameW.hpp"
  11.  
  12. #ifndef FWPRESEN_H
  13. #include "FWPresen.h"
  14. #endif
  15.  
  16. #ifndef FWPART_H
  17. #include "FWPart.h"
  18. #endif
  19.  
  20. #ifndef FWFRAME_H
  21. #include "FWFrame.h"
  22. #endif
  23.  
  24. #ifndef FWSELECT_H
  25. #include "FWSelect.h"
  26. #endif
  27.  
  28. #ifndef FWITERS_H
  29. #include "FWIters.h"
  30. #endif
  31.  
  32. #ifndef FWUTIL_H
  33. #include "FWUtil.h"
  34. #endif
  35.  
  36. #ifndef FWVIEWAS_H
  37. #include "FWViewAs.h"
  38. #endif
  39.  
  40. #ifndef FWEXCEPT_H
  41. #include "FWExcept.h"
  42. #endif
  43.  
  44. // ----- OS Layer -----
  45.  
  46. #ifndef FWODGEOM_H
  47. #include "FWODGeom.h"
  48. #endif
  49.  
  50. #ifndef FWWINDOW_H
  51. #include "FWWindow.h"
  52. #endif
  53.  
  54. // ----- Foundation Includes -----
  55.  
  56. #ifndef FWBNDSTR_H
  57. #include "FWBndStr.h"
  58. #endif
  59.  
  60. // ----- OpenDoc Includes -----
  61. #ifndef SOM_ODArbitrator_xh
  62. #include <Arbitrat.xh>
  63. #endif
  64.  
  65. #ifndef SOM_ODSession_xh
  66. #include <ODSessn.xh>
  67. #endif
  68.  
  69. #ifndef SOM_ODFacet_xh
  70. #include <Facet.xh>
  71. #endif
  72.  
  73. #ifndef SOM_ODFocusSet_xh
  74. #include <FocusSet.xh>
  75. #endif
  76.  
  77. #ifndef SOM_ODShape_xh
  78. #include <Shape.xh>
  79. #endif
  80.  
  81. #ifndef SOM_ODFrame_xh
  82. #include <Frame.xh>
  83. #endif
  84.  
  85. #if defined(__MWERKS__) && GENERATING68K
  86. // A hack to work around a bug
  87. #pragma import list somGetGlobalEnvironment
  88. #endif
  89.  
  90. //========================================================================================
  91. // RunTime Info
  92. //========================================================================================
  93.  
  94. #ifdef FW_BUILD_MAC
  95. #pragma segment fwpart2
  96. #endif
  97.  
  98. //========================================================================================
  99. //    Template Instantiations
  100. //========================================================================================
  101.  
  102. FW_DEFINE_AUTO_TEMPLATE(FW_TOrderedCollectionIterator, FW_CPresentation)
  103. FW_DEFINE_AUTO_TEMPLATE(FW_TOrderedCollection, FW_CPresentation)
  104. FW_DEFINE_AUTO_TEMPLATE(FW_TOrderedCollectionIterator, FW_CPrivDisplayFrame)
  105. FW_DEFINE_AUTO_TEMPLATE(FW_TOrderedCollection, FW_CPrivDisplayFrame)
  106.  
  107. #ifdef FW_USE_TEMPLATE_PRAGMAS
  108.  
  109. #pragma template_access public
  110. #pragma template FW_TOrderedCollection<FW_CPresentation>
  111. #pragma template FW_TOrderedCollectionIterator<FW_CPresentation>
  112. #pragma template FW_TOrderedCollection<FW_CPrivDisplayFrame>
  113. #pragma template FW_TOrderedCollectionIterator<FW_CPrivDisplayFrame>
  114.  
  115. #endif
  116.  
  117. //========================================================================================
  118. //    class FW_CPrivDisplayFrame
  119. //========================================================================================
  120.  
  121. //----------------------------------------------------------------------------------------
  122. //    FW_CPrivDisplayFrame::FW_CPrivDisplayFrame
  123. //----------------------------------------------------------------------------------------
  124.  
  125. FW_CPrivDisplayFrame::FW_CPrivDisplayFrame(Environment *ev, FW_CFrame* frame) :
  126.     fFrameID(frame->GetID(ev)),
  127.     fODFrame(frame->GetODFrame(ev)),
  128.     fFrame(frame)
  129. {
  130.     fODFrame->Acquire(ev);
  131. }
  132.  
  133. //----------------------------------------------------------------------------------------
  134. //    FW_CPrivDisplayFrame::FW_CPrivDisplayFrame
  135. //----------------------------------------------------------------------------------------
  136.  
  137. FW_CPrivDisplayFrame::FW_CPrivDisplayFrame(Environment *ev, ODID frameID) :
  138.     fFrameID(frameID),
  139.     fODFrame(NULL),
  140.     fFrame(NULL)
  141. {
  142. FW_UNUSED(ev);
  143. }
  144.  
  145. //----------------------------------------------------------------------------------------
  146. //    FW_CPrivDisplayFrame::~FW_CPrivDisplayFrame
  147. //----------------------------------------------------------------------------------------
  148.  
  149. FW_CPrivDisplayFrame::~FW_CPrivDisplayFrame()
  150. {
  151.     Release(somGetGlobalEnvironment());
  152. }
  153.  
  154. //----------------------------------------------------------------------------------------
  155. //    FW_CPrivDisplayFrame::Release
  156. //----------------------------------------------------------------------------------------
  157.  
  158. void FW_CPrivDisplayFrame::Release(Environment *ev)
  159. {
  160.     if (fODFrame)
  161.     {
  162.         fODFrame->SetPartInfo(ev, NULL);
  163.         fODFrame->Release(ev);
  164.         fODFrame = NULL;
  165.     }
  166. }
  167.  
  168. //========================================================================================
  169. //    class FW_CPresentation
  170. //========================================================================================
  171.  
  172. //----------------------------------------------------------------------------------------
  173. //    FW_CPresentation::FW_CPresentation
  174. //----------------------------------------------------------------------------------------
  175.  
  176. FW_CPresentation::FW_CPresentation(Environment *ev, 
  177.                                 FW_CPart* thePart, 
  178.                                 FW_CSelection* selection,
  179.                                 ODTypeToken presentationType,
  180.                                 ODTypeToken defaultEmbeddedFrameViewType) :
  181.     fPart(thePart),
  182.     fFrames(NULL),
  183.     fSelection(selection),
  184.     fPresentationType(presentationType),
  185.     fFocusSet(NULL),
  186.     fArbitrator(NULL),
  187.     fPartWindowFrame(NULL),
  188.     fViewAsThumbnail(NULL),
  189.     fViewAsSmallIcon(NULL),
  190.     fViewAsLargeIcon(NULL),
  191.     fDefaultEmbeddedFrameViewType(defaultEmbeddedFrameViewType),
  192.     fDragPending(FALSE)
  193. {
  194.     FW_ASSERT(thePart);
  195.     
  196.     fFrames = FW_NEW(FW_TOrderedCollection<FW_CPrivDisplayFrame>, ());
  197.  
  198.     fArbitrator = fPart->GetSession(ev)->GetArbitrator(ev);
  199.  
  200.     // ----- By default add all common foci to the presentation
  201.     //         (floating windows & dialogs will updated later)
  202.     fFocusSet = fArbitrator->CreateFocusSet(ev);
  203.     fFocusSet->Add(ev, FW_CPart::gKeyFocusToken);
  204.     fFocusSet->Add(ev, FW_CPart::gMenuFocusToken);
  205.     fFocusSet->Add(ev, FW_CPart::gSelectionFocusToken);
  206.     fFocusSet->Add(ev, FW_CPart::gClipboardFocusToken);
  207. }
  208.  
  209. //----------------------------------------------------------------------------------------
  210. //    FW_CPresentation::~FW_CPresentation
  211. //----------------------------------------------------------------------------------------
  212.  
  213. FW_CPresentation::~FW_CPresentation()
  214. {
  215.     FW_ASSERT(fViewAsThumbnail == NULL);        // Should already have been released
  216.     FW_ASSERT(fViewAsSmallIcon == NULL);
  217.     FW_ASSERT(fViewAsLargeIcon == NULL);
  218.  
  219.     delete fSelection;
  220.     
  221.     Environment* ev = somGetGlobalEnvironment();
  222.     
  223.     if (fFrames != NULL)
  224.     {
  225.         FW_CPrivDisplayFrame* displayFrame;
  226.         while ((displayFrame = fFrames->First()) != NULL)
  227.             PrivDeleteDisplayFrame(ev, displayFrame);
  228.         
  229.         delete fFrames;
  230.     }
  231.  
  232.     delete fFocusSet;
  233. }
  234.  
  235. //----------------------------------------------------------------------------------------
  236. //    FW_CPresentation::Invalidate
  237. //----------------------------------------------------------------------------------------
  238. // invalidShape should be in content coordinates
  239.  
  240. void FW_CPresentation::Invalidate(Environment *ev, ODShape* invalidShape, ODID sequenceNumber)
  241. {
  242.     FW_CPresentationFrameIterator ite(ev, this);
  243.     for (FW_CFrame* frame = ite.First(ev); ite.IsNotComplete(ev); frame = ite.Next(ev))
  244.     {
  245.         if (sequenceNumber == 0 || sequenceNumber == frame->GetSequenceNumber(ev))
  246.         {
  247.             FW_CAcquiredODShape aqInvalidShape;
  248.             if (invalidShape != NULL)
  249.             {
  250.                 FW_CAcquiredODTransform aqInternalTransform = frame->AcquireInternalTransform(ev, NULL);
  251.                 aqInvalidShape = invalidShape->Copy(ev);
  252.                 aqInvalidShape->Transform(ev, aqInternalTransform);
  253.             }
  254.             
  255.             frame->GetODFrame(ev)->Invalidate(ev, aqInvalidShape, NULL);        // if aqInvalidShape is NULL OpenDoc will use the aggregate
  256.                                                                                 // clip shape
  257.         }
  258.     }
  259. }
  260.  
  261. //----------------------------------------------------------------------------------------
  262. //    FW_CPresentation::Validate
  263. //----------------------------------------------------------------------------------------
  264. // validShape should be in content coordinates
  265.  
  266. void FW_CPresentation::Validate(Environment *ev, ODShape* validShape, ODID sequenceNumber)
  267. {
  268.     FW_CPresentationFrameIterator ite(ev, this);
  269.     for (FW_CFrame* frame = ite.First(ev); ite.IsNotComplete(ev); frame = ite.Next(ev))
  270.     {
  271.         if (sequenceNumber == 0 || sequenceNumber == frame->GetSequenceNumber(ev))
  272.         {
  273.             FW_CAcquiredODShape aqValidShape;
  274.             if (validShape != NULL)
  275.             {
  276.                 FW_CAcquiredODTransform aqInternalTransform = frame->AcquireInternalTransform(ev, NULL);
  277.                 aqValidShape = validShape->Copy(ev);
  278.                 aqValidShape->Transform(ev, aqInternalTransform);
  279.             }
  280.             
  281.             frame->GetODFrame(ev)->Validate(ev, aqValidShape, NULL);        // if aqInvalidShape is NULL OpenDoc will use the aggregate
  282.                                                                             // clip shape
  283.         }
  284.     }
  285. }
  286.  
  287. //----------------------------------------------------------------------------------------
  288. //    FW_CPresentation::Invalidate
  289. //----------------------------------------------------------------------------------------
  290. // invalidRect should be in content coordinates
  291.  
  292. void FW_CPresentation::Invalidate(Environment* ev, const FW_CRect& invalidRect, ODID sequenceNumber)
  293. {
  294.     FW_CAcquiredODShape aqShape = ::FW_NewODShape(ev, invalidRect);
  295.     Invalidate(ev, aqShape, sequenceNumber);
  296. }
  297.  
  298. //----------------------------------------------------------------------------------------
  299. //    FW_CPresentation::Validate
  300. //----------------------------------------------------------------------------------------
  301. // validRect should be in content coordinates
  302.  
  303. void FW_CPresentation::Validate(Environment* ev, const FW_CRect& validRect, ODID sequenceNumber)
  304. {
  305.     FW_CAcquiredODShape aqShape = ::FW_NewODShape(ev, validRect);
  306.     Validate(ev, aqShape, sequenceNumber);
  307. }
  308.  
  309. //----------------------------------------------------------------------------------------
  310. //    FW_CPresentation::ContentUpdated
  311. //------------------------------------------------------------------------
  312.  
  313. void FW_CPresentation::ContentUpdated(Environment* ev, ODUpdateID updateID)
  314. {
  315.     // When ContentUpdated is called because of updating a link, a change ID is supplied.
  316.     // Otherwise, we need to create a unique change ID -
  317.     if (updateID == kODUnknownUpdate)
  318.         updateID = fPart->GetSession(ev)->UniqueUpdateID(ev);
  319.  
  320.     FW_CPresentationFrameIterator ite(ev, this);
  321.     for (FW_CFrame* frame = ite.First(ev); ite.IsNotComplete(ev); frame = ite.Next(ev))
  322.     {
  323.         frame->GetODFrame(ev)->ContentUpdated(ev, updateID);
  324.     }
  325. }
  326.  
  327. //----------------------------------------------------------------------------------------
  328. //    FW_CPresentation::PrivAddFrame
  329. //----------------------------------------------------------------------------------------
  330.  
  331. void FW_CPresentation::PrivAddFrame(Environment *ev, FW_CFrame* frame)
  332. {
  333.     // ----- set up the last active frame ------
  334.     if (fPart->GetLastActiveFrame(ev) == NULL)
  335.     {
  336.         ODFocusSet* focusSet = frame->GetFocusSet(ev);
  337.         if (focusSet->Contains(ev, FW_CPart::gSelectionFocusToken))
  338.             fPart->PrivSetLastActiveFrame(frame);
  339.     }
  340.     
  341.     fFrames->AddLast(new FW_CPrivDisplayFrame(ev, frame));
  342. }
  343.  
  344. //----------------------------------------------------------------------------------------
  345. //    FW_CPresentation::PrivGetDisplayFrame
  346. //----------------------------------------------------------------------------------------
  347.  
  348. FW_CPrivDisplayFrame* FW_CPresentation::PrivGetDisplayFrame(FW_CFrame* frame) const
  349. {
  350.     FW_TOrderedCollectionIterator<FW_CPrivDisplayFrame> ite(fFrames);
  351.     for (FW_CPrivDisplayFrame* displayFrame = ite.First(); ite.IsNotComplete(); displayFrame = ite.Next())
  352.     {
  353.         if (displayFrame->fFrame == frame)
  354.             return displayFrame;
  355.     }
  356.     
  357.     return NULL;
  358. }
  359.  
  360. //----------------------------------------------------------------------------------------
  361. //    FW_CPresentation::PrivDeleteDisplayFrame
  362. //----------------------------------------------------------------------------------------
  363.  
  364. void FW_CPresentation::PrivDeleteDisplayFrame(Environment *ev, FW_CPrivDisplayFrame* displayFrame)
  365. {
  366.     // ----- First Remove it from the list -----
  367.     fFrames->Remove(displayFrame);
  368.  
  369.     // ----- if this frame was an "Open in Window" frame then ....
  370.     if (fPartWindowFrame == displayFrame->fFrame)
  371.     {
  372.         fPartWindowFrame = NULL;    
  373.         PrivInvalidateIconedFrame(ev);
  374.     }
  375.     
  376.     // ----- Now I can delete it
  377.     delete displayFrame;
  378. }
  379.  
  380. //----------------------------------------------------------------------------------------
  381. //    FW_CPresentation::PrivInvalidateIconedFrame
  382. //----------------------------------------------------------------------------------------
  383.  
  384. void FW_CPresentation::PrivInvalidateIconedFrame(Environment *ev)
  385. {
  386.     FW_CPresentationFrameIterator ite(ev, this);
  387.     for (FW_CFrame* aFrame = ite.First(ev); ite.IsNotComplete(ev); aFrame =  ite.Next(ev))
  388.     {
  389.         ODTypeToken viewType = aFrame->GetViewType(ev);
  390.         if (viewType == FW_CPart::gViewAsLargeIconToken || viewType == FW_CPart::gViewAsSmallIconToken)
  391.             aFrame->GetODFrame(ev)->Invalidate(ev, NULL, NULL);
  392.     }        
  393. }
  394.  
  395. //----------------------------------------------------------------------------------------
  396. //    FW_CPresentation::ReleaseAll
  397. //----------------------------------------------------------------------------------------
  398.  
  399. void FW_CPresentation::ReleaseAll(Environment *ev)
  400. {
  401.     FW_TOrderedCollectionIterator<FW_CPrivDisplayFrame> ite(fFrames);
  402.     for (FW_CPrivDisplayFrame* displayFrame = ite.First(); ite.IsNotComplete(); displayFrame = ite.Next())
  403.     {
  404.         displayFrame->Release(ev);
  405.     }
  406. }
  407.  
  408. //----------------------------------------------------------------------------------------
  409. //    FW_CPresentation::PrivFrameRemoved
  410. //----------------------------------------------------------------------------------------
  411.  
  412. void FW_CPresentation::PrivFrameRemoved(Environment *ev, FW_CFrame* frame, FW_Boolean toStorage)
  413. {
  414.     FW_Boolean wasLastActive = (fPart->GetLastActiveFrame(ev) == frame);
  415.     
  416.     // ----- Notify the frame -----
  417.     frame->FrameRemoved(ev, toStorage);
  418.     
  419.     // ----- Remove it from the list -----
  420.     FW_CPrivDisplayFrame* displayFrame = PrivGetDisplayFrame(frame);
  421.     FW_ASSERT(displayFrame);
  422.  
  423.     PrivDeleteDisplayFrame(ev, displayFrame);
  424.  
  425.     // ----- delete it if not shared -----
  426.     if (!frame->PrivInSharedWindow(ev))
  427.         delete frame;
  428.     
  429.     // ----- Set the last active frame to the first frame of this presentation -----    
  430.     if (wasLastActive)
  431.     {
  432.         FW_CPrivDisplayFrame* displayFrame = fFrames->First();
  433.         fPart->PrivSetLastActiveFrame(displayFrame ? displayFrame->fFrame : NULL);
  434.     }
  435. }
  436.  
  437. //----------------------------------------------------------------------------------------
  438. //    FW_CPresentation::CountFrame
  439. //----------------------------------------------------------------------------------------
  440.  
  441. unsigned long FW_CPresentation::CountFrame(Environment *ev) const
  442. {
  443. FW_UNUSED(ev);
  444.     return fFrames->Count();
  445. }
  446.  
  447. //----------------------------------------------------------------------------------------
  448. //    FW_CPresentation::Embed
  449. //----------------------------------------------------------------------------------------
  450.  
  451. void FW_CPresentation::Embed(Environment*    ev, 
  452.                                 ODPart*        embeddedPart,
  453.                                 ODFrame*     embeddedFrame,
  454.                                 ODType         frameType,
  455.                                 FW_MProxy*    proxy,
  456.                                 ODShape*    frameShape,
  457.                                 ODTypeToken viewType,
  458.                                 ODTypeToken    presentationType,
  459.                                 ODID        frameGroupID,
  460.                                 FW_Boolean    isOverlaid,
  461.                                 FW_Boolean    subFrame)
  462. {
  463. FW_UNUSED(ev);
  464. FW_UNUSED(embeddedPart);
  465. FW_UNUSED(embeddedFrame);
  466. FW_UNUSED(frameType);
  467. FW_UNUSED(proxy);
  468. FW_UNUSED(frameShape);
  469. FW_UNUSED(viewType);
  470. FW_UNUSED(presentationType);
  471. FW_UNUSED(frameGroupID);
  472. FW_UNUSED(isOverlaid);
  473. FW_UNUSED(subFrame);
  474.     FW_DEBUG_MESSAGE("FW_CPresentation::Embed  Should never have been called");
  475. }
  476.  
  477. //----------------------------------------------------------------------------------------
  478. //    FW_CPresentation::RemoveSiblingFrame
  479. //----------------------------------------------------------------------------------------
  480.  
  481. void FW_CPresentation::RemoveSiblingFrame(Environment* ev, FW_CFrame* frameToRemove)
  482. {
  483.     FW_ASSERT(frameToRemove->IsRequestedFrame(ev));    // Cannot remove a frame not requested
  484.     
  485.     FW_CAcquiredODFrame embeddingFrame = frameToRemove->AcquireContainingFrame(ev);
  486.     FW_CAcquiredODPart embeddingPart = embeddingFrame->AcquirePart(ev);
  487.     
  488.     embeddingPart->RemoveEmbeddedFrame(ev, frameToRemove->GetODFrame(ev));
  489. }
  490.  
  491. //----------------------------------------------------------------------------------------
  492. //    FW_CPresentation::RequestSiblingFrame
  493. //----------------------------------------------------------------------------------------
  494. //    returns kODNULLID if the request was not fulfilled
  495.  
  496. ODID FW_CPresentation::RequestSiblingFrame(Environment* ev,
  497.                                             FW_CFrame* baseFrame, 
  498.                                             ODShape* suggestedFrameShape,
  499.                                             ODTypeToken viewType,
  500.                                             FW_Boolean isOverlaid)
  501. {
  502.     FW_CAcquiredODFrame embeddingFrame = baseFrame->AcquireContainingFrame(ev);
  503.     FW_CAcquiredODPart embeddingPart = embeddingFrame->AcquirePart(ev);
  504.     
  505.     FW_CAcquiredODShape frameShape = suggestedFrameShape->Copy(ev);
  506.     FW_CAcquiredODFrame newFrame = embeddingPart->RequestEmbeddedFrame(ev,
  507.                                                                         embeddingFrame,
  508.                                                                         baseFrame->GetODFrame(ev),
  509.                                                                         frameShape,
  510.                                                                         fPart->GetODPart(ev),
  511.                                                                         viewType,
  512.                                                                         fPresentationType,
  513.                                                                         isOverlaid);
  514.     ODID newSequence = kODNULLID;
  515.     
  516.     if (newFrame != NULL)
  517.     {
  518.         FW_CFrame* fwFrame = FW_CFrame::ODtoFWFrame(ev, newFrame);
  519.         
  520.         ODID newFrameGroup = fwFrame->GetFrameGroup(ev);
  521.         newSequence = fwFrame->GetSequenceNumber(ev);
  522.     
  523.         // ----- Set the RequestedFrame flag -----
  524.         FW_CPresentationFrameIterator ite(ev, this, newFrameGroup, newSequence);
  525.         for (FW_CFrame* aFrame = ite.First(ev); ite.IsNotComplete(ev); aFrame =  ite.Next(ev))
  526.         {
  527.             aFrame->PrivSetRequestedFrame(ev);
  528.         }    
  529.     }
  530.     
  531.     return newSequence;
  532. }
  533.  
  534. //----------------------------------------------------------------------------------------
  535. //    FW_CPresentation::OpenPartWindow
  536. //----------------------------------------------------------------------------------------
  537.  
  538. ODID FW_CPresentation::OpenPartWindow(Environment* ev, FW_CFrame* sourceFrame, ODFacet* sourceFacet)
  539. {    
  540. FW_ASSERT(sourceFrame);
  541.  
  542.     FW_CWindow* window = NULL;
  543.     
  544.     if (fPartWindowFrame != NULL)
  545.     {
  546.         window = fPartWindowFrame->GetWindow(ev);
  547.     }
  548.     else
  549.     {
  550.         if (sourceFacet == NULL)
  551.         {
  552.             FW_CFrameFacetIterator ite(ev, sourceFrame);
  553.             sourceFacet = ite.First(ev);
  554.         }
  555.         FW_ASSERT(sourceFacet != NULL);
  556.         
  557.         // ----- Invalid all my frames if iconized -----
  558.         PrivInvalidateIconedFrame(ev);
  559.         
  560.         window = sourceFrame->NewPartWindow(ev, sourceFacet);                        
  561.         window->Show(ev);    // ATTENTION: Show should be before Select
  562.         
  563.         FW_CAcquiredODWindow odWindow = window->AcquireODWindow(ev);
  564.         
  565.         fPartWindowFrame = FW_CFrame::ODtoFWFrame(ev, odWindow->GetRootFacet(ev)->GetFrame(ev));
  566.         FW_ASSERT(fPartWindowFrame != NULL);
  567.     }
  568.         
  569.     window->Select(ev);
  570.     
  571.     return window->GetID(ev);
  572. }
  573.  
  574. //----------------------------------------------------------------------------------------
  575. // FW_CPresentation::PrivAcquireViewAs
  576. //----------------------------------------------------------------------------------------
  577.  
  578. FW_CViewAs* FW_CPresentation::PrivAcquireViewAs(Environment* ev, FW_CFrame* frame, ODTypeToken viewAsToken)
  579. {
  580.     FW_ASSERT(viewAsToken == FW_CPart::gViewAsThumbnailToken ||
  581.             viewAsToken == FW_CPart::gViewAsSmallIconToken ||
  582.             viewAsToken == FW_CPart::gViewAsLargeIconToken);
  583.             
  584.     FW_CViewAs* viewAs = NULL;
  585.     if (viewAsToken == FW_CPart::gViewAsThumbnailToken)
  586.     {
  587.         if (fViewAsThumbnail != NULL)
  588.             fViewAsThumbnail->Acquire();
  589.         else
  590.             fViewAsThumbnail = new FW_CViewAsThumbnail(ev);
  591.         viewAs = fViewAsThumbnail;
  592.     }
  593.     else if (viewAsToken == FW_CPart::gViewAsSmallIconToken)
  594.     {
  595.         if (fViewAsSmallIcon != NULL)
  596.             fViewAsSmallIcon->Acquire();
  597.         else
  598.             fViewAsSmallIcon = new FW_CViewAsSmallIcon(ev);
  599.         viewAs = fViewAsSmallIcon;            
  600.     }
  601.     else
  602.     {
  603.         if (fViewAsLargeIcon != NULL)
  604.             fViewAsLargeIcon->Acquire();
  605.         else
  606.             fViewAsLargeIcon = new FW_CViewAsLargeIcon(ev);
  607.         viewAs = fViewAsLargeIcon;            
  608.     }
  609.             
  610.     viewAs->Load(ev, frame);
  611.     return viewAs;
  612. }
  613.  
  614. //----------------------------------------------------------------------------------------
  615. // FW_CPresentation::PrivReleaseViewAs
  616. //----------------------------------------------------------------------------------------
  617.  
  618. void FW_CPresentation::PrivReleaseViewAs(FW_CViewAs* viewAs)
  619. {
  620.     FW_ASSERT(viewAs == fViewAsThumbnail || viewAs == fViewAsSmallIcon || viewAs == fViewAsLargeIcon);
  621.     
  622.     if (viewAs->Release() == 0)
  623.     {
  624.         if (viewAs == fViewAsThumbnail)
  625.             fViewAsThumbnail = NULL;
  626.         else if (viewAs == fViewAsSmallIcon)
  627.             fViewAsSmallIcon = NULL;
  628.         else
  629.             fViewAsLargeIcon = NULL;
  630.     }
  631. }
  632.  
  633. //----------------------------------------------------------------------------------------
  634. //    FW_CPresentation::UpdateViewAs
  635. //----------------------------------------------------------------------------------------
  636.  
  637. void FW_CPresentation::UpdateViewAs(Environment* ev)
  638. {
  639.     if (fViewAsThumbnail != NULL)
  640.         fViewAsThumbnail->Unload(ev);
  641.     
  642.     if (fViewAsSmallIcon != NULL)
  643.         fViewAsSmallIcon->Unload(ev);
  644.     
  645.     if (fViewAsLargeIcon != NULL)
  646.         fViewAsSmallIcon->Unload(ev);
  647. }
  648.  
  649. //----------------------------------------------------------------------------------------
  650. // FW_CPresentation::GetPartWindow
  651. //----------------------------------------------------------------------------------------
  652.  
  653. FW_CWindow* FW_CPresentation::GetPartWindow(Environment* ev) const
  654. {
  655.     return fPartWindowFrame ? fPartWindowFrame->GetWindow(ev) : NULL;
  656. }
  657.  
  658. //----------------------------------------------------------------------------------------
  659. //    FW_CPresentation::AdoptFocusSet
  660. //----------------------------------------------------------------------------------------
  661.  
  662. void FW_CPresentation::AdoptFocusSet(Environment* ev, ODFocusSet* newFocusSet)
  663. {
  664. #ifdef FW_DEBUG
  665.     // No frame should be active when changing the focus set because it is used
  666.     // during activation/deactivation
  667.     FW_CPresentationFrameIterator ite(ev, this);
  668.     for (FW_CFrame* aFrame = ite.First(ev); ite.IsNotComplete(ev); aFrame =  ite.Next(ev))
  669.     {
  670.         FW_ASSERT(aFrame->HasSelectionFocus(ev) == FALSE);
  671.     }
  672. #endif
  673.     
  674.     delete fFocusSet;
  675.     if (newFocusSet)
  676.         fFocusSet = newFocusSet;
  677.     else
  678.         fFocusSet = fArbitrator->CreateFocusSet(ev);    // Empty focus set
  679. }
  680.  
  681. //----------------------------------------------------------------------------------------
  682. //    FW_CPresentation::SetFocusSet
  683. //----------------------------------------------------------------------------------------
  684.  
  685. void FW_CPresentation::SetFocusSet(Environment* ev, ODFocusSet* newFocusSet)
  686. {
  687. #ifdef FW_DEBUG
  688.     // No frame should be active when changing the focus set because it is used
  689.     // during activation/deactivation
  690.     FW_CPresentationFrameIterator ite(ev, this);
  691.     for (FW_CFrame* aFrame = ite.First(ev); ite.IsNotComplete(ev); aFrame =  ite.Next(ev))
  692.     {
  693.         FW_ASSERT(aFrame->HasSelectionFocus(ev) == FALSE);
  694.     }
  695. #else
  696. FW_UNUSED(ev);
  697. #endif
  698.         
  699.     fFocusSet = newFocusSet;
  700. }
  701.  
  702. //----------------------------------------------------------------------------------------
  703. //    FW_CPresentation::PrivNewFrame
  704. //----------------------------------------------------------------------------------------
  705. //    PrivNewFrame is used internaly for example by the about dialog. Part should never
  706. //    have to subclass FW_CPresentation. Use FW_CPart::NewFrame instead.
  707.  
  708. FW_CFrame* FW_CPresentation::PrivNewFrame(Environment *ev,
  709.                                         ODFrame* odFrame, 
  710.                                         FW_Boolean fromStorage)
  711. {
  712. FW_UNUSED(ev);
  713. FW_UNUSED(odFrame);
  714. FW_UNUSED(fromStorage);
  715.     return NULL;
  716. }